//
//  SKUDetailTbv_V4_Head_Title_Cell.m
//  ZITHER
//
//  Created by weixin on 2018/11/9.
//  Copyright © 2018 weixn. All rights reserved.
//

#import "SKUDetailTbv_V4_Head_Title_Cell.h"

@implementation SKUDetailTbv_V4_Head_Title_Cell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code

    self.viewBorder.backgroundColor = [UIColor colorWithHex:@"f5f5f5"];
    [self.viewBorder mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(0);
        make.right.equalTo(self).offset(0);
        make.height.mas_equalTo(10);
        make.bottom.equalTo(self).offset(0);
    }];
    [self setUI];
    [self setMasonry];

}

-(void)setModel:(skuDetailModel *)model
{
    _model = model;
    
    self.labName.text = model.goodNameNative;
    self.anotherName.text = model.alias;
    
    self.brandName.text = model.brandName;
    self.brandanotherName.text = model.brandNameNative;
    self.seriesName.text = model.seriesName;
    self.seriesanotherName.text = model.seriesNameNative;

}

-(void)setUI{
    [self addSubview:self.labName];
    [self addSubview:self.anotherName];
    [self addSubview:self.branView];
    [self addSubview:self.seriesView];
}

-(void)setMasonry{

    BaseLab *lab = [BaseLab initCustomLab:@"型号" color:HexColor(0x999999) font: [UIFont fontWithName:@"PingFang-SC-Regular" size:12]];
    [self addSubview:lab];
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self.mas_top).offset(12);
        make.height.mas_equalTo(13);
    }];
    
    
    [self.labName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(13);
        make.top.equalTo(self.mas_top).offset(35);
        make.height.mas_equalTo(30);
    }];
    
    [self.anotherName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self.labName.mas_bottom).offset(-3);
    }];
    
//    self.branView.backgroundColor = [UIColor redColor];
    [self.branView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.anotherName.mas_bottom).offset(25);
        make.left.right.equalTo(self).offset(0);
        make.height.mas_equalTo(50);
    }];
    
    BaseLab *lab1 = [BaseLab initCustomLab:@"品牌" color:HexColor(0x999999) font: [UIFont fontWithName:@"PingFang-SC-Regular" size:12]];
    [self addSubview:lab1];
    [lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self.brandName.mas_top).offset(-15);
        make.height.mas_equalTo(13);
    }];
//    self.brandName.backgroundColor = [UIColor greenColor];
    [self.brandName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.branView.mas_top).offset(8);
        make.left.equalTo(self).offset(15);
    }];
    
//    self.brandanotherName.backgroundColor = [UIColor greenColor];
    [self.brandanotherName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.brandName.mas_bottom).offset(-2);
        make.left.equalTo(self).offset(15);
    }];
    
    [self.seriesView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.branView.mas_bottom).offset(20);
        make.left.right.equalTo(self.branView).offset(0);
        make.height.mas_equalTo(50);
        make.bottom.equalTo(self.mas_bottom).offset(-10);
    }];
    BaseLab *lab2 = [BaseLab initCustomLab:@"系列" color:HexColor(0x999999) font: [UIFont fontWithName:@"PingFang-SC-Regular" size:12]];
    [self addSubview:lab2];
    [lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self.seriesName.mas_top).offset(-15);
        make.height.mas_equalTo(13);
    }];
    
    [self.seriesName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.seriesView.mas_centerY).offset(0);
        make.left.equalTo(self).offset(15);
    }];
    
    [self.seriesanotherName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.seriesName.mas_bottom).offset(5);
        make.left.equalTo(self).offset(15);
    }];
    
    for (int i = 0 ; i<2; i++) {
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 1, 1 )];
        imageView.image = [UIImage imageNamed:@"sku_btn_into"];
        imageView.contentMode = 2;
        if (i== 0 ) {
            [self.branView addSubview:imageView];
            
            [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(self.branView.mas_centerY).offset(0);
                make.right.equalTo(self).offset(-15);
                make.width.mas_offset(5);
                make.height.mas_offset(11);
            }];
        }else{
            [self.seriesView addSubview:imageView];
            
            [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(self.seriesView.mas_centerY).offset(0);
                make.right.equalTo(self).offset(-15);
                make.width.mas_offset(5);
                make.height.mas_offset(11);
            }];
        }
       
    }

    
}

-(BaseLab *)labName{
    if (!_labName) {
        _labName = [[BaseLab alloc]initializeFrame:CGRectMake(15, 450, 242, 40) text:@"30003/000P-8200" font:10 textColor:[UIColor blackColor] isBold:NO numberOfLines:1];
//        _labName.font = [UIFont fontWithName:@"CSD-Block-Bold" size:40];
        _labName.font = [UIFont fontWithName:@"Arial-BoldMT" size:30];

        _labName.adjustsFontSizeToFitWidth = YES;
        _labName.minimumScaleFactor = 10;
       
    }
    return _labName;
}
-(BaseLab *)anotherName{
    if (!_anotherName) {
        _anotherName = [[BaseLab alloc]initializeFrame:CGRectMake(15, 486, 28, 14) text:@"绿鬼" font:10 textColor:[UIColor blackColor] isBold:NO numberOfLines:1];
        _anotherName.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
    }
    return _anotherName;
}

-(UIView *)branView{
    if (!_branView) {
        _branView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 1, 1)];
        _branView.backgroundColor = [UIColor randomColor];
        [_branView addSubview:self.brandName];
        [_branView addSubview:self.brandanotherName];
    }
    return _branView;
}

-(UIView *)seriesView{
    if (!_seriesView) {
        _seriesView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 1, 1)];
        _seriesView.backgroundColor = [UIColor randomColor];
        [_seriesView addSubview:self.seriesName];
        [_seriesView addSubview:self.seriesanotherName];
        
    }
    return _seriesView;
}


-(BaseLab *)brandName{
    if (!_brandName) {
        _brandName = [[BaseLab alloc]initializeFrame:CGRectMake(15, 486, 28, 14) text:@"品牌名" font:10 textColor:[UIColor blackColor] isBold:NO numberOfLines:1];
        _brandName.font = [UIFont fontWithName:@"PingFangSC-Medium" size:17];
    }
    return _brandName;
}

-(BaseLab *)brandanotherName{
    if (!_brandanotherName) {
        _brandanotherName = [[BaseLab alloc]initializeFrame:CGRectMake(15, 486, 28, 14) text:@"品牌其他名" font:10 textColor:[UIColor blackColor] isBold:NO numberOfLines:1];
        _brandanotherName.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
    }
    return _brandanotherName;
}

-(BaseLab *)seriesName{
    if (!_seriesName) {
        _seriesName = [[BaseLab alloc]initializeFrame:CGRectMake(15, 486, 28, 14) text:@"系列名" font:10 textColor:[UIColor blackColor] isBold:NO numberOfLines:1];
        _seriesName.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:17];
    }
    return _seriesName;
}

-(BaseLab *)seriesanotherName{
    if (!_seriesanotherName) {
        _seriesanotherName = [[BaseLab alloc]initializeFrame:CGRectMake(15, 486, 28, 14) text:@"系列其他名" font:10 textColor:[UIColor blackColor] isBold:NO numberOfLines:1];
        _seriesanotherName.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
        _seriesanotherName.hidden = YES;
    }
    return _seriesanotherName;
}




@end
